import React, { useEffect, useState, useMemo, useRef, useContext, createContext, forwardRef, useReducer } from 'react';
// 根据单位计算获取体重useReducer
const jxstate={
	weight:0,weight_unit:0
}
function getweightreducer(state:{}, action:{type:0}) {
	switch (action.type) {
		case 0:
			weight:jxstate.weight.toFixed(2),
			weight_unit:"Kg"
		break
		case 1:
		return {
			weight:(jxstate.weight*2.2046).toFixed(1),
			weight_unit:"Lb"
		}
		default:
		throw new Error();
	}
}
const [jxrdustate, jxdispatch] = useReducer(getweightreducer, jxstate);
export default (Yystspage)

function forunit(jxstate:{},wulist:string[]){
	const jxdata = {
		weight:"",weight_unit:""
	}
	switch(jxstate.weight_unit){
	case 0:
		jxdata.weight = parseFloat(jxstate.weight).toFixed(2)
		jxdata.weight = wulist[jxstate.weight_unit]
		break
	case 1:
		jxdata.weight = (parseFloat(jxstate.weight)*2.2046).toFixed(1)
		jxdata.weight = wulist[jxstate.weight_unit]
		break
	return jxdata
}